use video_subtitle_gen_rs::video_extrator::{self, SrtExtractResult};
use std::error::Error;
use std::env;
use std::path::Path;

#[test]
fn audio_convert_test_work()->Result<(),Box<dyn Error+'static>>{
    let mut  demo_video_path= env::current_dir()?;
    demo_video_path.push("tests");
    demo_video_path.push("demo_audio_convert_test.mp4");
    assert!(demo_video_path.exists());
    let audio_result= video_extrator::audio_convert(&demo_video_path,&None)?;
    assert!(audio_result.exists());
    Ok(())
}
#[test]
fn srt_extract_test_work()->Result<(),Box<dyn Error+'static>>{
    let mut  demo_audio_path= env::current_dir()?;
    demo_audio_path.push("tests");
    demo_audio_path.push("demo_audio_extract_test.wav");
    assert!(demo_audio_path.exists());
    let srt_result= video_extrator::srt_extract(&demo_audio_path,true,&None)?;
    if let SrtExtractResult::WirteIo(srt_path)= srt_result{
        assert!(Path::new(&srt_path).exists());
    }
    Ok(())
}
#[tokio::test]
async fn srt_translate_test_work()->Result<(),Box<dyn Error+'static>>{
    let mut  demo_srt_path= env::current_dir()?;
    demo_srt_path.push("tests");
    demo_srt_path.push("demo_translate_origin.srt");
    assert!(demo_srt_path.exists());
    let translate_result= video_extrator::srt_translate(&demo_srt_path,&None).await;
    assert!(translate_result.is_ok());
    Ok(())
}